# 打印键值key相同，value值不同的内容
# dict1 = {1:'a',2:'b',3:'c',4:100,5:200}
# dict2 = {1:'x',2:'y',3:'z',4:100,5:200}
# for key1 in dict1:
#     for key2 in dict2:
#         if key1 == key2 and dict1[key1] != dict2[key2]:
#             print(key2,dict2[key2])


dict_list={} #创建空字典
dict_list["name"]="liaogan" #添加值
dict_list['age']=20
dict_list['higt']=175

for key in dict_list:#遍历key的值
    print(key)

del dict_list['age']#删除元素
print(dict_list)

print(dict_list.items())  #列遍字典的键值对
print(dict_list.keys())  #获取字典的key
print(dict_list.values())  #获取字典的values

print(dict_list)
print(dict_list.get('higt'),dict_list.get("name"),dict_list.values(),dict_list.keys(),dict_list.items())


dict1 = dict(
    case_id='123',  # 获取case_id
    case_name="456",  # 获取case_name
    method="789",  # 获取method
)
print(dict1)


#有一个列表，列表中包含字典，取出字典key对应values的值
'''方式1'''
# list1=[{'a':'teacher','b':2,'d':4}]
# print([list2[key] for list2 in list1  for key in list2])

'''方式2'''
# alist1=[]
# alist2=[]
# for list2 in list1:
#     print(list2)
#     for key1 in list2:
#         print(key1,list2[key1])
#         alist1.append(list2[key1])
#         alist2.append(key1)
# print(alist1)
# print(alist2)




# #有一个列表，列表中包含字典，取出字典key对应values的值
# list = [{"feed": "推荐食谱", "high": "170", "love": "打篮球"}, {"company": "百果园"}, {"salary": "25000"}]
#
# '''方法1'''
# alist=[]
# for list3 in list:#取出整个字典
#     print(list3)
#     for key in list3:#在字典中取出key的值
#         print(key,list3[key])  #打印对应的key，values值
#         alist.append(list3[key])
#         # print(list3[key])#循环打印字典对应key的值
# print(alist)

'''方法2'''
# print([list3[key] for list3 in list   for key in list3])


# list1=[{'name':'liaogan','age':'18','sex':27}]
# onelist=[]
# for one in list1:
#     for one1 in  one:
#         onelist.append(one[one1])
# print(onelist)

